function goPage(pageNum) {
	if (/^\d+$/.test(pageNum) === false) {
		return;
	}
	if (pageNum < 1) { pageNum = 1;}
	var oUrl = location.href.toString();
	if (oUrl.indexOf("page=") === -1) {
		oUrl += oUrl.indexOf('?') < 0 ? "?" : "&";
		location.href = oUrl + 'page=' + pageNum;
	} else {
		location.href = oUrl.replaceAll(/(page=[0-9]+)/g, 'page=' + pageNum);
	}
}

function showPages(options) {
	options = options || {};
	options.totalPage = options.totalPage || 1;
	options.currentPage = options.currentPage || 1;
	options.id = options.id || '#showPages';
	if (options.totalPage <= 1) {
		return;
	}
	if (options.currentPage < 1) options.currentPage = 1;
	if (options.currentPage > options.totalPage) {
		options.currentPage = options.totalPage;
	}
	var beginPage = 1;
	if (options.currentPage > 3) {
		beginPage = options.currentPage - 3;
	}
	var endPage = beginPage + 6;
	if (endPage > options.totalPage) {
		endPage = options.totalPage;
		if (endPage > 6) {
			beginPage = endPage - 6;
		}
	}
	var pageHtml = "";
	if (beginPage > 1) {
		pageHtml += '<a href="javascript:goPage(1);" class="layui-btn layui-btn-primary" title="首页">首页</a>';
		//if (beginPage > 2) {
		//	pageHtml += '<a href="javascript:goPage(' + (options.currentPage - 1) + ')">&lt;</a>';
		//}
	}
	for (var i = beginPage; i <= endPage; i++) {
		if (options.currentPage === i) {
			pageHtml += "<a href='javascript:void(0)' class='layui-btn layui-btn-primary current'>" + i + "</a>";
		} else {
			pageHtml += "<a href='javascript:goPage(" + i + ")' class='layui-btn layui-btn-primary'>" + i + "</a>";
		}
	}
	if (endPage < options.totalPage) {
		//if ((endPage + 1) < options.totalPage) {
		//	pageHtml += '<a href="javascript:goPage(' + (options.currentPage + 1) + ')">&gt;</a>';
		//}
		pageHtml += '<a href="javascript:goPage(' + options.totalPage + ');" class="layui-btn layui-btn-primary" title="尾页">尾页</a>';
	}
	$(options.id).html(pageHtml);
}